package com.ymtms.arrivalofgoods.controller;

import com.netflix.discovery.converters.Auto;
import com.ymtms.arrivalofgoods.exception.CheckException;
import com.ymtms.arrivalofgoods.pojo.CheckGoodsReceive;
import com.ymtms.arrivalofgoods.service.CheckGoodsReceiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@CrossOrigin
public class CheckReceiveController {
    @Autowired
    private CheckGoodsReceiveService checkGoodsReceiveService;


    @ResponseBody
    @RequestMapping("/checkReceive")
    public Map checkReceiveGoods(Integer[] keys) {
        Map map = new HashMap();

        if(keys==null||keys.length==0){
            map.put("code","500");
            map.put("msg", "请先选择");
            return map;
}

        try {
            checkGoodsReceiveService.modifyStatusByKeys(keys);
            map.put("code", "0");
            map.put("msg", "success");
        } catch (CheckException e) {
            map.put("code", "500");
            map.put("msg", "faild");
            e.printStackTrace();
        }
        return map;

    }


}
